package com.java110.mall.shop.smo.impl;


import com.java110.mall.shop.dao.IShopAuditServiceDao;
import com.java110.intf.shop.IShopAuditInnerServiceSMO;
import com.java110.dto.shop.ShopAuditDto;
import com.java110.po.shop.ShopAuditPo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 店铺审核内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ShopAuditInnerServiceSMOImpl extends BaseServiceSMO implements IShopAuditInnerServiceSMO {

    @Autowired
    private IShopAuditServiceDao shopAuditServiceDaoImpl;


    @Override
    public int saveShopAudit(@RequestBody  ShopAuditPo shopAuditPo) {
        int saveFlag = 1;
        shopAuditServiceDaoImpl.saveShopAuditInfo(BeanConvertUtil.beanCovertMap(shopAuditPo));
        return saveFlag;
    }

     @Override
    public int updateShopAudit(@RequestBody  ShopAuditPo shopAuditPo) {
        int saveFlag = 1;
         shopAuditServiceDaoImpl.updateShopAuditInfo(BeanConvertUtil.beanCovertMap(shopAuditPo));
        return saveFlag;
    }

     @Override
    public int deleteShopAudit(@RequestBody  ShopAuditPo shopAuditPo) {
        int saveFlag = 1;
        shopAuditPo.setStatusCd("1");
        shopAuditServiceDaoImpl.updateShopAuditInfo(BeanConvertUtil.beanCovertMap(shopAuditPo));
        return saveFlag;
    }

    @Override
    public List<ShopAuditDto> queryShopAudits(@RequestBody  ShopAuditDto shopAuditDto) {

        //校验是否传了 分页信息

        int page = shopAuditDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            shopAuditDto.setPage((page - 1) * shopAuditDto.getRow());
        }

        List<ShopAuditDto> shopAudits = BeanConvertUtil.covertBeanList(shopAuditServiceDaoImpl.getShopAuditInfo(BeanConvertUtil.beanCovertMap(shopAuditDto)), ShopAuditDto.class);

        return shopAudits;
    }


    @Override
    public int queryShopAuditsCount(@RequestBody ShopAuditDto shopAuditDto) {
        return shopAuditServiceDaoImpl.queryShopAuditsCount(BeanConvertUtil.beanCovertMap(shopAuditDto));    }

    public IShopAuditServiceDao getShopAuditServiceDaoImpl() {
        return shopAuditServiceDaoImpl;
    }

    public void setShopAuditServiceDaoImpl(IShopAuditServiceDao shopAuditServiceDaoImpl) {
        this.shopAuditServiceDaoImpl = shopAuditServiceDaoImpl;
    }
}
